

########################################################
#  Figures and tables for legislative compliance paper #
########################################################


########################################################
#  Setting directory and loading data                  #
########################################################
setwd("C:/Users/oyvinsti/Dropbox/!PhD/PaperProjects/LegislativeCompliance/LegislativeComplianceNewData")


load("ReplicationData.RData")

firstRow <- dt[which(dt$tstart == 0),]

########################################################
#               Packages                               #
########################################################
library(survival)
library(ggplot2)
library(stargazer)
library(grid)
library(GGally)
library(tidyr)


########################################################
#         Defining functions                           #
########################################################
hrtimeplot <- function(model, term1, term2,maxduration=max(model$y[,"time"])){
  logtime <- log(seq(1, maxduration))
  combcoef <-model$coefficients[term1]+logtime*model$coefficients[term2]
  vcov <- model$var
  
  combcoef.se <- sqrt(vcov[term1,term1]+
                        logtime^2*vcov[term2,term2]+2*logtime*vcov[term1,term2])
  
  plotdata <-data.frame(coef=exp(combcoef), 
                        time=seq(1,maxduration), 
                        upper90=exp(combcoef+1.65*combcoef.se),
                        lower90=exp(combcoef-1.65*combcoef.se),
                        upper95=exp(combcoef+1.96*combcoef.se),
                        lower95=exp(combcoef-1.96*combcoef.se), 
                        upper99=exp(combcoef+2.575*combcoef.se),
                        lower99=exp(combcoef-2.575*combcoef.se))
  
  plot <- ggplot(plotdata) + geom_line(aes(y=coef, x=time))+
    geom_ribbon(aes(ymin=lower90, ymax=upper90, x=time), alpha = 0.3)+
    geom_ribbon(aes(ymin=lower95, ymax=upper95, x=time), alpha = 0.2)+
    geom_ribbon(aes(ymin=lower99, ymax=upper99, x=time), alpha = 0.1)+
    geom_hline(yintercept=1, linetype = 2, alpha=0.5)+
    ylab("Relative hazard")+
    xlab("Time in days")+
    theme_classic()+
    theme(legend.title=element_blank())
  print(plot)
  return(plot)
}


logtime <- function(x,t, ...){x*log(t)}

coxTable <-function(models){
  coef.table<-function(model){
    
    coefs <- model$coefficients
    ses <- sqrt(diag(model$var))
    
    coef.table <-as.data.frame(ifelse(abs(coefs/ses) >= 2.57, 
                                      paste(round(exp(coefs), digits=3), "***", sep=""), 
                                      ifelse(abs(coefs/ses) >= 1.96, 
                                             paste(round(exp(coefs), digits=3), "**", sep=""),
                                             ifelse(abs(coefs/ses) >= 1.65, 
                                                    paste(round(exp(coefs), digits=3), "*", sep=""),
                                                    round(exp(coefs), digits=3)))))
    colnames(coef.table) <-deparse(substitute(model)) 
    coef.table$vars <-names(coefs)
    return(coef.table)
  }
  ci.table <-function(model){
    coefs <- model$coefficients
    ses <- sqrt(diag(model$var))
    ci.table<-as.data.frame(as.character(paste("(",round(exp(coefs -1.96*ses),digits=3), ",",
                                               round(exp(coefs +1.96*ses),digits=3),")", sep="")))
    
    colnames(ci.table) <-deparse(substitute(model)) 
    ci.table$vars <-names(model$coefficients)
    return(ci.table)
  }
  
  hazards <- coef.table(models[[1]])
  
  for(i in 2:length(models)){
    hazards <-merge(hazards, coef.table(models[[i]]), by="vars", all.x=T, all.y=T, sort=F)
  }
  
  ci <- ci.table(models[[1]])
  for(i in 2:length(models)){
    ci <-merge(ci, ci.table(models[[i]]), by="vars", all.x=T, all.y=T, sort=F)
  }
  
  for(i in 1:ncol(ci)){
    ci[,i] <-as.character(ci[,i])
    hazards[,i] <-as.character(hazards[,i])
  }
  results <-as.data.frame(matrix(NA, ncol=ncol(hazards), nrow=nrow(hazards)*2))
  results[seq(1,nrow(results)-1, by=2),] <- hazards
  results[seq(2,nrow(results), by=2),] <- ci
  results[seq(2,nrow(results), by=2),1] <-""
  
  
  
  annex<-as.data.frame(matrix(NA, nrow=5,ncol=ncol(results)))
  annex[,1] <-c("Log-likelihood null model", "Log-likelihood","AIC","Number of events", "Number of observations")
  for(i in 1:length(models)){
    annex[1,i+1] <-round(summary(models[[i]])$loglik[1], digits=2)
    annex[2,i+1] <-round(summary(models[[i]])$loglik[2], digits=2)
    annex[3,i+1] <-round(extractAIC(models[[i]])[2], digits=2)
    annex[4,i+1] <-summary(models[[i]])$nevent
    if(is.na(gsub("dt", "firstRow",models[[i]]$call$data)[3])){
      annex[5,i+1] <-nrow(na.omit(firstRow[,names(models[[i]]$assign2)[grepl("tt(",names(models[[i]]$assign2),
                                                                             fixed = T)==F &
                                                                         grepl(":",names(models[[i]]$assign2), fixed = T)==F &
                                                                         grepl("I(",names(models[[i]]$assign2), fixed = T)==F &
                                                                         grepl("frailty(",names(models[[i]]$assign2), fixed = T)==F]])) 
    }
    else{
      annex[5,i+1] <-nrow(na.omit(firstRow[eval(parse(text = gsub("dt", "firstRow",models[[i]]$call$data)[3])),names(models[[i]]$assign2)[grepl("tt(",names(models[[i]]$assign2),
                                                                                                                                                fixed = T)==F &
                                                                                                                                            grepl(":",names(models[[i]]$assign2), fixed = T)==F &
                                                                                                                                            grepl("I(",names(models[[i]]$assign2), fixed = T)==F &
                                                                                                                                            grepl("frailty(",names(models[[i]]$assign2), fixed = T)==F]]))  
    }
    
  }
  results <-rbind(results, annex)
  
  return(results)
}


vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)





########################################################
#              Descriptive statistics                  #
########################################################

# summary statistics 

dt$v2jureview_ord
vars <- dt[which(dt$tstart ==0),c("legislation",
                                  "jurisprudence","practical",
                                  "publication","exe_adm",
                                  "anyIndividualMeasure",
                                  "NumberOfMeasureTypes",
                                  "marginOfAppreciationJudgment", 
                                  "v2jureview_ord",
                                  "polconiii",
                                  "unicameral","dpi_majoritarian","execap","polityfrompolity",
                             "newdemocracy1",
                                  "numberOfArticlesViolated",
                             "article2violated",
                               "article3violated",
                               "article5violated",
                               "article6violated",
                               "article8violated",
                               "article10violated",
                               "article13violated",
                               "article14violated",
                               "protocol1_1violated",
                             "friendlySettlement",
                                  "Judgment.Year", 
                             "postProtocol11", 
                             "postCoMWorkingmethodChange",
                             "postProtocol14")]
varnames <- colnames(vars)

colnames(vars) <- c("Need for legislative change","Need for jurisprudential change",
                    "Need for practical measure", "Need to publish judgment", "Need for executive action",
                    "Need for individual measure",
                    "Number of types of measures needed",
                    "Margin of appreciation discussed", 
                    "Domestic judicial review",
                    "Political constraints index", 
                    "Unicameral legislature", "Majoritarian electoral system", 
                    "Capacity",
                   "Polity-index","New democracy", "Number of violations", 
                   "Right to life violation",
                   "Prohibition of torture violation",
                   "Right to liberty violation",
                   "Right to fair trial violation",
                   "Right to privacy and family life violated",
                   "Freedom of expression violation",
                   "Right to effective remedy violation",
                   "Prohibition of discrimination violation",
                   "Property rights violations",
                   "Friendly settlement" ,"Year of judgment", 
                   "After protocol 11", 
                   "After 2006 change in CoM Working methods", 
                   "After protocol 14")
stargazer(vars, title="Summary Statistics", out="descriptiveStatistics.tex", font.size="scriptsize", label="tab:descriptives")


stargazer(vars, type = "html",
          title="Summary Statistics", out="descriptiveStatistics.html", font.size="scriptsize", label="tab:descriptives")




########################################################
##              Models                                 #
########################################################
### models ####

mod1<-coxph(Surv(tstart, tstop, compliance)~legislation+jurisprudence+ practical+
              publication+exe_adm+
              anyIndividualMeasure+
              polconiii+
            +execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
              article2violated+
              article3violated+
              article5violated+
              article6violated+
              article8violated+
              article10violated+
              article13violated+
              article14violated+
              protocol1_1violated+
              friendlySettlement+
             Judgment.Year+
              postProtocol11+
              postCoMWorkingmethodChange+
              postProtocol14+
              tt(legislation)+
              tt(newdemocracy1)+
                tt(postProtocol14)+
              frailty(respondent, "gamma"),
            data=dt, tt=logtime)
summary(mod1)

mod2<-coxph(Surv(tstart, tstop, compliance) ~ legislation +
              NumberOfMeasureTypes+
              polconiii+
              execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
              article2violated+
              article3violated+
              article5violated+
              article6violated+
              article8violated+
              article10violated+
              article13violated+
              article14violated+
              protocol1_1violated+
              friendlySettlement+
              Judgment.Year+
              postProtocol11+
              postCoMWorkingmethodChange+
              postProtocol14+
               +tt(legislation)+
               tt( NumberOfMeasureTypes)+
               tt(newdemocracy1)+
              tt(postProtocol14)+
              frailty(respondent, "gamma"),
            data=dt, 
            tt=logtime)
summary(mod2)

mod3<-coxph(Surv(tstart, tstop, compliance)~legislation+
              NumberOfMeasureTypes+
              polconiii+execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
              article2violated+
              article3violated+
              article5violated+
              article6violated+
              article8violated+
              article10violated+
              article13violated+
              article14violated+
              protocol1_1violated+
              friendlySettlement+
              Judgment.Year+
              postProtocol11+
              postCoMWorkingmethodChange+
              postProtocol14+
              +tt(legislation)+
              tt( NumberOfMeasureTypes)+
              tt(newdemocracy1)+
              tt(postProtocol14)+
              frailty(respondent, "gamma")
            , data=dt[which(dt$polityfrompolity > 5),], tt=logtime)
summary(mod3)

mod4<-coxph(Surv(tstart, tstop, compliance)~legislation+
              NumberOfMeasureTypes+
              polconiii+execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
              article2violated+
              article3violated+
              article5violated+
              article6violated+
              article8violated+
              article10violated+
              article13violated+
              article14violated+
              protocol1_1violated+
              friendlySettlement+
              Judgment.Year+
              postProtocol11+
              postCoMWorkingmethodChange+
              postProtocol14+
              +tt(legislation)+
              tt(NumberOfMeasureTypes)+
              tt(newdemocracy1)+
              tt(postProtocol14)+
              frailty(respondent, "gamma")
            , data=dt[which(dt$NumberOfMeasureTypes> 0),], tt=logtime)
summary(mod4)


mod5 <-coxph(Surv(tstart, tstop, compliance)~
               marginOfAppreciationJudgment +
               NumberOfMeasureTypes+
               +execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
               article2violated+
               article3violated+
               article5violated+
               article6violated+
               article8violated+
               article10violated+
               article13violated+
               article14violated+
               protocol1_1violated+
               friendlySettlement+
               Judgment.Year+
               postProtocol11+
               postCoMWorkingmethodChange+
               postProtocol14+
               tt(NumberOfMeasureTypes)+
               tt(newdemocracy1)+
               tt(postProtocol14)+
               frailty(respondent, "gamma"),
             data=dt[which(dt$legislation ==1),], 
             tt=logtime)

summary(mod5)


mod6 <-coxph(Surv(tstart, tstop, compliance)~
               v2jureview_ord +
               NumberOfMeasureTypes+
               +execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
               article2violated+
               article3violated+
               article5violated+
               article6violated+
               article8violated+
               article10violated+
               article13violated+
               article14violated+
               protocol1_1violated+
               friendlySettlement+
               Judgment.Year+
               postProtocol11+
               postCoMWorkingmethodChange+
               postProtocol14+
               tt(NumberOfMeasureTypes)+
               tt(newdemocracy1)+
               tt(postProtocol14)+
               frailty(respondent, "gamma"),
             data=dt[which(dt$legislation ==1),],
             tt=logtime)


mod7 <-coxph(Surv(tstart, tstop, compliance)~
                 polconiii +
                 NumberOfMeasureTypes+
                 +execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
               article2violated+
               article3violated+
               article5violated+
               article6violated+
               article8violated+
               article10violated+
               article13violated+
               article14violated+
               protocol1_1violated+
                 friendlySettlement+
                 Judgment.Year+
                 postProtocol11+
                 postCoMWorkingmethodChange+
                 postProtocol14+
               tt(NumberOfMeasureTypes)+
                 tt(newdemocracy1)+
                  tt(postProtocol14)+
                 frailty(respondent, "gamma"),
               data=dt[which(dt$legislation ==1),],
               tt=logtime)


mod8 <-coxph(Surv(tstart, tstop, compliance)~
                     unicameral+
                     NumberOfMeasureTypes+
                     +execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
               article2violated+
               article3violated+
               article5violated+
               article6violated+
               article8violated+
               article10violated+
               article13violated+
               article14violated+
               protocol1_1violated+
                     friendlySettlement+
                     Judgment.Year+
                     postProtocol11+
                     postCoMWorkingmethodChange+
                     postProtocol14+
               tt(NumberOfMeasureTypes)+
               tt(newdemocracy1)+
               tt(postProtocol14)+
                     frailty(respondent, "gamma"),
                   data=dt[which(dt$legislation ==1),], 
                   tt=logtime)


mod9 <-coxph(Surv(tstart, tstop, compliance)~
                       dpi_majoritarian+
                       NumberOfMeasureTypes+
                       +execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
               article2violated+
               article3violated+
               article5violated+
               article6violated+
               article8violated+
               article10violated+
               article13violated+
               article14violated+
               protocol1_1violated+
                       friendlySettlement+
                       Judgment.Year+
                       postProtocol11+
                       postCoMWorkingmethodChange+
                       postProtocol14+
               tt(NumberOfMeasureTypes)+
                       tt(newdemocracy1)+
                       tt(postProtocol14)+
                       frailty(respondent, "gamma"),
                     data=dt[which(dt$legislation ==1),], 
                     tt=logtime)










regressionTable <- coxTable(list(mod1, mod2, mod3,mod4,mod5, 
                                 mod6, mod7, mod8, mod9))


regressionTable[,1]

regressionTable <- rbind(
  regressionTable[47:48,], ## leg
  regressionTable[55:56,], ## leg*log(t)
  regressionTable[63:64,], ## margin of appreciation
  regressionTable[65:66,], ## judicial review
  regressionTable[45:46,], ## polcon
  regressionTable[61:62,], ## unicameral
  regressionTable[67:68,], ## electoral system
  regressionTable[49:54,], ## dummies other measures
  regressionTable[57:60,], ## dummies other measures
  regressionTable[41:44,], ## count other measures
  regressionTable[1:6,],   ## execap, polity, newdemocracy
  regressionTable[37:38,], ## new democracy * log(t)
  regressionTable[7:36,],  ## case controls
  regressionTable[39:40,], ## postProtocol14 *log(t)
  regressionTable[69:73,]) ## model info
                         
                         
                         

regressionTable[seq(1,68, by = 2),1] <- c("Need for legislative change", 
                                          "Need for legislative change*log(t)", 
                                          "Margin of appreciation discussed", 
                                          "Domestic judicial review",
                                          "Political constraints index", 
                                          "Unicameral system",
                                          "Majority/plurality-based electoral system", 
                                          "Need for jurisprudential change",
                                          "Need for practical measures", 
                                          "Need for publication", 
                                          "Need for executive action", 
                                          "Need for individual measure", 
                                          "Number of needed measure types",
                                          "Number of needed measure types*log(t)",
                                          "Capacity", 
                                          "Polity-index", 
                                          "New democracy",
                                          "New democracy*log(t)", 
                                          "Number of articles violated", 
                                          "Right to life violation",
                                          "Prohibition of torture violation",
                                          "Right to liberty violation",
                                          "Right to fair trial violation",
                                          "Right to privacy and family life violated",
                                          "Freedom of expression violation",
                                          "Right to effective remedy violation",
                                          "Prohibition of discrimination violation",
                                          "Property rights violations",
                                          "Friendly settlement", 
                                          "Judgment year", 
                                          "After protocol 11", 
                                          "After 2006 change in CoM Working methods", 
                                          "After protocol 14", 
                                          "After protocol 14*log(t)")
                                       
colnames(regressionTable) <- c("", "Model 1", "Model 2", "Model 3", 
                               "Model 4", "Model 5", "Model 6", "Model 7", "Model 8", "Model 9")
stargazer(regressionTable,
          rownames = F,
          summary = F,
          out="regressionTable.tex",
          label = "tab:regressionTable",
          font.size="tiny",
          title="Shared-frailty Cox regression models: Need for legislative change and compliance",
          notes=c("Estimates in hazard ratios. 95 per cent confidence intervals in parentheses.",
                  "$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01"),
          column.sep.width="1pt")


stargazer(regressionTable,
          type = "html",
          rownames = F,
          summary = F,
          out="regressionTable.html",
          label = "tab:regressionTable",
          font.size="tiny",
          title="Shared-frailty Cox regression models: Need for legislative change and compliance",
          notes=c("Estimates in hazard ratios. 95 per cent confidence intervals in parentheses.",
                  "$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01"),
          column.sep.width="1pt")



### HR ratio plots  ####
names(coefficients(mod1))
plot1 <- hrtimeplot(mod1,1,26)+
  ylim(0,2.2)+
  ggtitle("Model 1: Controlling for the other types of measures needed")+
  theme(plot.title = element_text(size=6))
names(coefficients(mod2))
plot2 <- hrtimeplot(mod2,1,22)+
  ylim(0,2.2)+
  ggtitle("Model 2: Controlling for the number of other measure types needed")+
  theme(plot.title = element_text(size=6))

names(coefficients(mod3))
plot3 <- hrtimeplot(mod3,1,22)+
  ylim(0,2.2)+
  ggtitle("Model 3: Controlling for number of other measure types.\nOnly Democracies")+
  theme(plot.title = element_text(size=7))

names(coefficients(mod4))
plot4 <-hrtimeplot(mod4,1,22)+
  ylim(0,2.2)+
  ggtitle("Model 4: Controlling for number of other measure types.\nExcluding judgments requiring only monetary payments")+
  theme(plot.title = element_text(size=7))





pdf("hrtimeplot.pdf", width=6, height=6)
pushViewport(viewport(layout = grid.layout(1, 2)))
print(plot1,
      vp = vplayout(1, 1))
print(plot2, 
      vp = vplayout(1, 2))
dev.off()


png("hrtimeplot.png")
pushViewport(viewport(layout = grid.layout(1, 2)))
print(plot1,
      vp = vplayout(1, 1))
print(plot2, 
      vp = vplayout(1, 2))
dev.off()

##### Robustness check 2 ######
jurModel<-coxph(Surv(tstart, tstop, compliance)~jurisprudence+
                  NumberOfMeasureTypes+
                  polconiii+execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
                  article2violated+
                  article3violated+
                  article5violated+
                  article6violated+
                  article8violated+
                  article10violated+
                  article13violated+
                  article14violated+
                  protocol1_1violated+
                  friendlySettlement+
                  Judgment.Year+
                  postProtocol11+
                  postCoMWorkingmethodChange+
                  postProtocol14+
                  tt( NumberOfMeasureTypes)+
                  tt(newdemocracy1)+
                  tt(postProtocol14)+
                  frailty(respondent, "gamma")
                , data = dt, tt=logtime)

summary(jurModel)

exeModel<-coxph(Surv(tstart, tstop, compliance)~exe_adm+
                  NumberOfMeasureTypes+
                  polconiii+execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
                  article2violated+
                  article3violated+
                  article5violated+
                  article6violated+
                  article8violated+
                  article10violated+
                  article13violated+
                  article14violated+
                  protocol1_1violated+
                  friendlySettlement+
                  Judgment.Year+
                  postProtocol11+
                  postCoMWorkingmethodChange+
                  postProtocol14+
                  tt( NumberOfMeasureTypes)+
                  tt(newdemocracy1)+
                  tt(postProtocol14)+
                  frailty(respondent, "gamma")
                , data=dt, tt=logtime)

summary(exeModel)
names(coefficients(exeModel))


pubModel<-coxph(Surv(tstart, tstop, compliance)~publication+ 
                  NumberOfMeasureTypes+
                  polconiii+execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
                  article2violated+
                  article3violated+
                  article5violated+
                  article6violated+
                  article8violated+
                  article10violated+
                  article13violated+
                  article14violated+
                  protocol1_1violated+
                  friendlySettlement+
                  Judgment.Year+
                  postProtocol11+
                  postCoMWorkingmethodChange+
                  postProtocol14+
                  tt( NumberOfMeasureTypes)+
                  tt(newdemocracy1)+
                  tt(postProtocol14)+
                  frailty(respondent, "gamma")
                , data=dt, tt=logtime)
summary(pubModel)

pracModel<-coxph(Surv(tstart, tstop, compliance)~practical+ NumberOfMeasureTypes+
                   polconiii+execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
                   article2violated+
                   article3violated+
                   article5violated+
                   article6violated+
                   article8violated+
                   article10violated+
                   article13violated+
                   article14violated+
                   protocol1_1violated+
                   friendlySettlement+
                   Judgment.Year+
                   postProtocol11+
                   postCoMWorkingmethodChange+
                   postProtocol14+
                   tt( NumberOfMeasureTypes)+
                   tt(newdemocracy1)+
                   tt(postProtocol14)+
                   frailty(respondent, "gamma")
                 , data=dt, tt=logtime)

summary(pracModel)

IndividualModel<-coxph(Surv(tstart, tstop, compliance) ~ anyIndividualMeasure+  NumberOfMeasureTypes+
                         polconiii+execap+polityfrompolity+newdemocracy1+numberOfArticlesViolated+
                         article2violated+
                         article3violated+
                         article5violated+
                         article6violated+
                         article8violated+
                         article10violated+
                         article13violated+
                         article14violated+
                         protocol1_1violated+
                         friendlySettlement+
                         Judgment.Year+
                         postProtocol11+
                         postCoMWorkingmethodChange+
                         postProtocol14+
                         tt( NumberOfMeasureTypes)+
                         tt(newdemocracy1)+
                         tt(postProtocol14)+
                   frailty(respondent, "gamma")
                 , data=dt, tt=logtime)
summary(IndividualModel)
#plot(cox.zph(IndividualModel, "rank"), col = "red")





otherMeasureTable <- coxTable(list(jurModel, exeModel,pubModel, pracModel, IndividualModel))


otherMeasureTable[,1]


otherMeasureTable <- rbind(otherMeasureTable[53:54,], 
                           otherMeasureTable[49:50,], 
                           otherMeasureTable[47:48,], 
                           otherMeasureTable[51:52,], 
                           otherMeasureTable[55:56,], 
                           otherMeasureTable[1:2,], 
                           otherMeasureTable[41:42,], 
                           otherMeasureTable[5:10,], 
                           otherMeasureTable[43:44,], 
                           otherMeasureTable[3:4,], 
                           otherMeasureTable[11:40,], 
                           otherMeasureTable[45:46,],
                           otherMeasureTable[57:61,])
                           
                           

otherMeasureTable[seq(1,55, by = 2),1] <- c("Need for jurisprudential change", 
                                            "Need for executive action", 
                                            "Need for publication of judgment", 
                                            "Need for practical measure", 
                                            "Need for individual measure", 
                                            "Number of measure types", 
                                            "Number of measure types*log(t)", 
                                            "Capacity", 
                                            "Polity-index",
                                            "New democracy", 
                                            "New democracy*log(t)",
                                            "Political constraints", 
                                            "Number of articles violated",
                                            "Right to life violation",
                                            "Prohibition of torture violation",
                                            "Right to liberty violation",
                                            "Right to fair trial violation",
                                            "Right to privacy and family life violated",
                                            "Freedom of expression violation",
                                            "Right to effective remedy violation",
                                            "Prohibition of discrimination violation",
                                            "Property rights violations",
                                            "Friendly settlement", 
                                            "Judgment year", 
                                            "After protocol 11", 
                                            "After 2006 change in CoM Working methods", 
                                            "After protocol 14", 
                                            "After protocol 14*log(t)")

colnames(otherMeasureTable) <- c("", "Model 10", "Model 11", "Model 12", "Model 13", "Model 14")
 stargazer(otherMeasureTable, summary=F,
           font.size="tiny",label="tab:otherMeasures",
           title="Shared frailty Cox models:  Effects of other compliance tasks",
           out="OtherMeasures.tex", rownames=F,
           notes=c("Estimates in hazard ratios. 95 per cent confidence intervals in parentheses.",
                   "$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01"))










